package com.cs.service.orders.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cs.mapper.OrdersMapper;
import com.cs.pojo.Order;
import com.cs.pojo.User;
import com.cs.service.orders.IOrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class OrderServiceImpl extends ServiceImpl<OrdersMapper, Order> implements IOrdersService {
    @Autowired
    private OrdersMapper ordersMapper;

//    public LambdaQueryWrapper<Order> lambdaQueryWrapper;

    public OrderServiceImpl() {
    }

    @Override
    public IPage<Order> getPage(int currentPage, int pageSize) {
        LambdaQueryWrapper<Order> lambdaQueryWrapper=new LambdaQueryWrapper<>();
        IPage<Order> page=new Page<>(currentPage,pageSize);
        ordersMapper.selectPage(page,lambdaQueryWrapper);
        return page;
    }

    @Override
    public IPage<Order> getPageByPhone(int currentPage, int pageSize, String phone) {
        LambdaQueryWrapper<Order> lambdaQueryWrapper=new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Order::getPhone,phone);
        IPage<Order> page=new Page<>(currentPage,pageSize);
        ordersMapper.selectPage(page,lambdaQueryWrapper);
        return page;
    }

}
